<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title> 小程序管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">

  <link rel="stylesheet" href="/Public/layui/css/layui.css"  media="all">
  <style type="text/css">
    .layui-table{
      text-align: center;
    }
    .layui-table td, .layui-table th{
      text-align: center;
    }
  </style>
</head>
<body>
<div class="layui-layout layui-layout-admin">

  <!--菜单列表-->
  <div id = "divhead"></div>
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding:0 15px;">
      <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>论坛管理</legend>
      </fieldset>
      <table class="layui-table">
        <colgroup>
          <col width="100">
        </colgroup>
        <thead>
        <tr>
          <th>ID</th>
          <th>标题</th>
          <th>内容</th>
          <th>相关书籍</th>
          <th>文章类型</th>
          <th>点赞数目</th>
          <th>浏览数目</th>
          <th>添加时间</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <?php if(is_array($res["list"])): foreach($res["list"] as $key=>$vo): ?><tr>
            <td><?php echo ($vo["id"]); ?></td>
            <td><?php echo ($vo["title"]); ?></td>
            <td><?php echo ($vo["content"]); ?></td>
            <td><?php echo ($vo["xiangguanbook"]); ?></td>
            <td><?php echo ($vo["wenzhangtype"]); ?></td>
            <td><?php echo ($vo["dianzan_num"]); ?></td>
            <td><?php echo ($vo["liulan_num"]); ?></td>
            <td><?php echo ($vo["time"]); ?></td>
            <td>
              <button data-id="<?php echo ($vo["id"]); ?>" class="edit-book layui-btn layui-btn-small">编辑</button>
              <button class="layui-btn layui-btn-small">删除</button>
            </td>
          </tr><?php endforeach; endif; ?>
        </tbody>
      </table>
      <input id = "count" hidden value = "<?php echo ($res['count']); ?>"/>
      <div id="page-box"></div>
    </div>
  </div>

  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © 2017-2018 <a href="https://www.58zltc.com" target="_blank">  </a> All Rights Reserved.
  </div>
</div>
<script src="/Public/layui/layui.js" charset="utf-8"></script>
<script src="/Public/js/jquery-1.11.1.min.js" charset="utf-8"></script>
<script>
    $(function(){
        $('#divhead').load('/index.php/TongCheng/Index/menu.html');
    })
    //JavaScript代码区域
    layui.use(['element','laypage','layer'], function(){
        var element = layui.element
            ,$ = layui.jquery
            ,layer = layui.layer
            ,laypage = layui.laypage;
        var count = $("#count").val();

        laypage.render({
            elem: 'page-box'
            ,count: count
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            ,jump: function(obj){
                console.log(obj)
            }
        });
        $(".edit-book").on('click', function(event) {
            var id = $(this).data('id');
            layer.open({
                type: 2,
                title: '编辑商品',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['1000px', '700px'],
                content: '<?php echo U("edit");?>?id='+ id
            });
        });
    });
</script>
</body>
</html>